#ifndef _Function_Init_H_
#define _Function_Init_H_

#include "SC92F742x_C.H"
#include "intrins.H"

#define uchar unsigned char
#define uint unsigned int

#define IAPROM  0x00	  //0x00：选择ROM区操作  0x02：选择EEPROM区操作
#define IAPEPPROM  0x02	  //0x00：选择ROM区操作  0x02：选择EEPROM区操作

#define my_bool bit

//定时器初始化
extern void bsp_Timer_Init(void);
extern void bsp_timer2_init(void);   //定时器2 433M检测初始化
extern void enable_timer2_tr2(void); //定时器2 开始计数
extern void disable_timer2_tr2(void);//定时器2 停止计数
extern void clear_timer2_rcap2(void);//定时器2 计数值 清零
extern unsigned int get_timer2_rcap2(void); //获取定时器2 计数值
extern unsigned long get_systick_clock(void);

//串口初始化
extern void bsp_Uart0_Init(uint Freq,unsigned long int baud);
extern void bsp_Uart0_send_byte(unsigned char val);
extern void lvprintf(char* harder,int num);
extern void bsp_sendstring(unsigned char *string);
//智能模组串口
void bsp_Uart1_Init(uint Freq,unsigned long int baud);
void bsp_Uart1_send_byte(unsigned char val);

//PWM初始化
extern void bsp_PWM_Init(void);
extern void bsp_enable_PWM(unsigned char speed);
extern void bsp_disable_PWM(void);

//IO口初始化
extern void bsp_IO_Init(void);

//外部中断初始化
extern void bsp_EX_Init(void);

//辅助定时器,产生系统时钟
extern void bsp_BTM_Init(void);


//ADC采集数据
/***********ADC采样口选择*************/
enum Channel 
{				AIN0=0,
        AIN1,
			  AIN2,
			  AIN3,
			  AIN4,
			  AIN5,
			  AIN6,
			  AIN7
};
extern uint get_adc_value(int ch);

//以下是eeprom的存储数据位置分配

	//下面的地址保存 433M 遥控器对码数据
	#define SER_NUMBER_0_START_ADD 0x00
	#define SER_NUMBER_1_START_ADD 0x04
	#define SER_NUMBER_2_START_ADD 0x08
	#define SER_NUMBER_3_START_ADD 0x0C
	#define SER_NUMBER_4_START_ADD 0x10
	//对码值偏移量
	#define SER_NUMBER_OFFSET_ADD (4U)
		//对码值的 尾地址
		#define SER_NUMBER_END_ADD (SER_NUMBER_4_START_ADD + SER_NUMBER_OFFSET_ADD)
		//保存对码值的下标 尾地址
		#define SER_NUMBER_POINTER (SER_NUMBER_END_ADD + 1U)
	//下面的地址保存hall行程
	#define HALL_NUMBER_H (SER_NUMBER_POINTER + 1U)
	#define HALL_NUMBER_L (HALL_NUMBER_H + 1U)
	//保存电机方向
	#define MOTOR_CONFIG_DIR (HALL_NUMBER_L + 1U)
	//线控模式
	#define WIRE_CONTROL_MODE (MOTOR_CONFIG_DIR + 1U)

extern void bsp_eeprom_write_byte(uint Address,uchar value);
extern uchar bsp_eeprom_read_byte(uint Address);


#endif